<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/core" prefix="c"%>
<%@ taglib uri="/tags/fmt" prefix="fmt"%>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript">
		function validate(){
			var someChecked = false;  
			if(document.InstructionPurchaseDetailSearchForm.radioId.length != undefined){
				for (var i=0; i < document.InstructionPurchaseDetailSearchForm.radioId.length; i++) {
				   if (document.InstructionPurchaseDetailSearchForm.radioId[i].checked){
				      someChecked = true;
				      break;
				   }
				 }	
			}else{				
				if(document.InstructionPurchaseDetailSearchForm.radioId.checked){
					someChecked = true;
				}	
			}
			return someChecked;
		}
		
		function submitForm(action){			
			if(validate()){
		    	var form = document.getElementById('mainForm');
		    	form.action = action;
		    	form.submit();
	    	}
		}
</script>

<html:form action="/ipdSearchCustomerResult.do" styleId="mainForm">
<br />
<table align="center" width="400" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
	<tr>
		<td class="etiqueta">
			<bean:message key="message.futurepurchase.customer.search"/>:<br/>
		</td>
		<td colspan="2" style="text-align: center;" class="etiqueta_campo">			
			<html:text property="customerViewSearch.description" styleId="customerViewSearch.description" styleClass="campo_texto"/>			
			<html:submit value="..." styleClass="boton_short" />
		</td>
	
	</tr>
</table>	

<br />

<table id="tabla" align="center" width="400" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
  <tr>
	<td colspan="3" class="titulocolumna" align="center"> <bean:message key="label.common.results"/> </td>
  </tr>  
  <tr>
  	<td class="etiqueta" align="center" width="30">&nbsp;&nbsp;</td>  	
  	<td class="columnadatoNon" align="center" width="90"> <bean:message key="message.futurepurchase.customer.code"/> </td>
  	<td class="columnadatoNon" align="center" width="280"> <bean:message key="error.description"/> </td>  	
  </tr>   
  <logic:notEmpty name="listOfCustomers">  	
		<logic:iterate id="row" name="listOfCustomers" indexId="int_i">
			<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">																			
				<td align="center">	
					<bean:define id="numberValue"><bean:write name="row" property="customerId"/></bean:define>
					<html:radio property="customerViewSearch.customerId" styleId="radioId" value="<%=numberValue%>" />
				</td>										
				<td align="center"><bean:write name="row" property="customerId"/></td>
				<td align="left"><bean:write name="row" property="description"/></td>					
			</tr>
		</logic:iterate>
	</logic:notEmpty>
	<tr>
	<td colspan="3" align="left" class="columnadatoPar">		
		 <logic:notEmpty name="listOfCustomers">   
			<html:button styleId="selectButton" property="submitAction" onclick="javascript:submitForm('ipdSelectCustomer.do')" styleClass="boton_large"><bean:message key="label.common.select"/></html:button>&nbsp;&nbsp;
		 </logic:notEmpty>
		 <logic:empty name="listOfCustomers">   
			<html:button styleId="selectButton" property="submitAction" disabled="true" onclick="javascript:submitForm('ipdSelectCustomer.do')" styleClass="boton_large"><bean:message key="label.common.select"/></html:button>&nbsp;&nbsp;
		 </logic:empty>					
		<html:button styleClass="boton" property="backButton" onclick="location.href='goAddInstructionPurchaseDetail.do';"> <bean:message key="label.common.cancel"/> </html:button>											
	</td>
	</tr>
</table>
</html:form>
<script>
document.getElementById('customerViewSearch.description').value = "";	  
</script>
<br />
<br />